import Vue from "vue";
import VueRouter from "vue-router";
import store from "../store";

const _import = path => import(`@/modules/index/views/${path}`);

Vue.use(VueRouter);

const routes = [
    {
        path: "/",
        redirect: "/home"
        // redirect: "/model/list"
    },
    {
        path: "/login",
        name: "login",
        meta: { title: "登录" },
        component: () => _import("login.vue")
    },
    {
        path: "/home",
        name: "Home",
        redirect: "/index",
        meta: {
            title: "首页"
        },
        component: () => import("@/modules/index/layout/index.vue"),
        children: [
            {
                path: "/index", //首页
                name: "index",
                meta: { title: "概览" },
                component: () => _import("Home.vue")
            },
            {
                path: "/datalist",
                name: "dataList",
                meta: {
                    title: "建模数据",
                    breadcrumb: []
                },
                component: () => _import("dataAdmin/list.vue")
            },
            {
                path: "/dataedit",
                name: "dataEdit",
                meta: {
                    title: "新建建模数据",
                    breadcrumb: ["dataList"]
                },
                component: () => _import("dataAdmin/edit.vue")
            },
            {
                path: "/datadetail",
                name: "dataDetail",
                meta: {
                    title: "数据集详情",
                    breadcrumb: ["dataList"]
                },
                component: () => _import("dataAdmin/detail.vue")
            },
            {
                path: "/tagList",
                name: "tagList",
                meta: {
                    title: "发布的任务"
                },
                component: () => _import("tagAdmin/index")
            },
            {
                path: "/tagList/mine",
                name: "tagListMine",
                meta: {
                    title: "接收的任务"
                },
                component: () => _import("tagAdmin/minePage")
            },
            {
                path: "/tagList/addTask",
                name: "tagListAddTask",
                meta: {
                    title: "新建标注任务",
                    breadcrumb: ["tagList"]
                },
                component: () => _import("tagAdmin/release/addTask")
            },
            {
                path: "/tagList/textDetail",
                name: "textDetail",
                meta: {
                    title: "文本分类任务",
                    breadcrumb: ["tagListMine"]
                },
                component: () => _import("tagAdmin/mine/text/detail")
            },
            {
                path: "/tagList/imageDetail",
                name: "imageDetail",
                meta: {
                    title: "图片分类任务",
                    breadcrumb: ["tagListMine"]
                },
                component: () => _import("tagAdmin/mine/image/detail")
            },
            {
                path: "/tagList/voiceDetail",
                name: "voiceDetail",
                meta: {
                    title: "语音分类任务",
                    breadcrumb: ["tagListMine"]
                },
                component: () => _import("tagAdmin/mine/voice/detail")
            },
            {
                path: "/tagList/objectDetail",
                name: "objectDetail",
                meta: {
                    title: "物体检查任务",
                    breadcrumb: ["tagListMine"]
                },
                component: () => _import("tagAdmin/mine/object/detail")
            },
            {
                path: "/prolist",
                name: "proList",
                meta: {
                    title: "我的项目"
                },
                component: () => _import("proAdmin/list.vue")
            },
            {
                path: "/moduleImport",
                name: "moduleImport",
                meta: {
                    title: "模型导入"
                },
                component: () => _import("proAdmin/moduleImport/list.vue")
            },
            {
                path: "/moduleImport/addTask",
                name: "moduleImportAddTask",
                meta: {
                    title: "新增模型",
                    breadcrumb: ["moduleImport"]
                },
                component: () => _import("proAdmin/moduleImport/addTask.vue")
            },
            {
                path: "/moduleImport/test",
                name: "moduleImportTest",
                meta: {
                    title: "新建预测",
                    breadcrumb: ["moduleImport"]
                },
                component: () => _import("proAdmin/moduleImport/test.vue")
            },
            {
                path: "/moduleImport/detail",
                name: "moduleImportDetail",
                meta: {
                    title: "模型导入部署详情"
                },
                component: () => _import("proAdmin/moduleImport/detail.vue")
            },
            {
                path: "/forecastList",
                name: "forecastList",
                meta: {
                    title: "我的预测"
                },
                component: () => _import("proAdmin/forecastList.vue")
            },
            {
                path: "/prolist/proedit",
                name: "proEdit",
                meta: {
                    title: "编辑项目",
                    breadcrumb: ["proList"]
                },
                component: () => _import("proAdmin/edit.vue")
            },
            {
                path: "/prolist/protest",
                name: "proTest",
                meta: {
                    title: "测试模型",
                    breadcrumb: ["proList"]
                },
                component: () => _import("proAdmin/test.vue")
            },
            {
                path: "/prolist/prodetail",
                name: "proDetail",
                meta: {
                    title: "项目详情",
                    breadcrumb: ["proList"]
                },
                component: () => _import("proAdmin/detail.vue")
            },
            {
                path: "/modellist",
                name: "modellist",
                meta: {
                    title: "我的模型"
                },
                component: () => _import("modelAdmin/list.vue")
            },

            {
                path: "/model/forecast",
                name: "modelForecast",
                meta: {
                    title: "新建预测",
                    breadcrumb: ["modelList", "modelDetail"]
                },
                component: () => _import("modelAdmin/forecast.vue")
            },
            {
                path: "/openAbility",
                name: "openAbility",
                meta: {
                    title: "开放能力"
                },
                component: () => _import("openAbility/list.vue")
            },
            {
                path: "/openAbility/nlp",
                name: "openAbilityNlp",
                meta: {
                    title: "自然语言处理",
                    breadcrumb: ["openAbility"]
                },
                component: () => _import("openAbility/nlp.vue")
            },
            {
                path: "/openAbility/ocr",
                name: "openAbilityOcr",
                meta: {
                    title: "OCR识别",
                    breadcrumb: ["openAbility"]
                },
                component: () => _import("openAbility/ocr.vue")
            },
            {
                path: "/modelPublishAdmin",
                name: "modelPublishAdmin",
                meta: {
                    title: "模型发布管理"
                },
                component: () => _import("modelPublishAdmin/list.vue")
            },

            // 前沿算法诊断
            {
                path: "/model/list",
                name: "modelList",
                meta: {
                    title: "前沿算法诊断"
                },
                component: () => _import("modelAdmin/modelList.vue")
            },
            {
                path: "/model/addModel",
                name: "addModel",
                meta: {
                    title: "新建模型",
                    breadcrumb: ["modelList"]
                },
                component: () => _import("modelAdmin/addModel/index.vue")
            },
            {
                path: "/model/importModel",
                name: "importModel",
                meta: {
                    title: "导入模型",
                    breadcrumb: ["modelList"]
                },
                component: () => _import("modelAdmin/importModel/index.vue")
            },
            {
                path: "/model/detail",
                name: "modelDetail",
                meta: {
                    title: "模型详情",
                    breadcrumb: ["modelList"]
                },
                component: () => _import("modelAdmin/modelDetail.vue")
            },

            //前沿算法预测
            {
                path: "/model/predictList",
                name: "modelPredictList",
                meta: {
                    title: "前沿算法预测"
                },
                component: () => _import("modelPredict/modelList.vue")
            },
            {
                path: "/model/modelPredictList",
                name: "addPredictModel",
                meta: {
                    title: "新建模型",
                    breadcrumb: ["modelPredictList"]
                },
                component: () => _import("modelPredict/addModel/index.vue")
            },
            {
                path: "/model/predictDetail",
                name: "predictDetail",
                meta: {
                    title: "模型详情",
                    breadcrumb: ["modelPredictList"]
                },
                component: () => _import("modelPredict/modelDetail.vue")
            },
            {
                path: "/model/predictForecast",
                name: "modelPredictForecast",
                meta: {
                    title: "新建预测",
                    breadcrumb: ["modelPredictList", "predictDetail"]
                },
                component: () => _import("modelPredict/forecast.vue")
            },
            //经典算法诊断-左列表-分页查询
            {
                path: "/code/List",
                name: "codeList",
                meta: {
                    title: "经典算法诊断"
                },
                component: () => _import("codeAdmin/index.vue")
            },
            //轻量化算法诊断代码裁剪
            {
                path: "/code/shortcut",
                name: "shortcut",
                meta: {
                    title: "经典算法诊断"
                },
                component: () => _import("shortcut/index.vue")
            },
            //轻量化算法诊断代码裁剪
            {
                path: "/code/previewCodeCut",
                name: "previewCodeCut",
                meta: {
                    title: "经典算法预测"
                },
                component: () => _import("previewCodeCut/index.vue")
            },

            //经典算法诊断-左列表-新增
            {
                path: "/code/addDetect",
                name: "addDetect",
                meta: {
                    title: "经典算法诊断"
                },
                component: () => _import("codeAdmin/components/addDetect.vue")
            },

            //经典算法诊断-右列表-新增
            {
                path: "/code/addAlgoFile",
                name: "addAlgoFile",
                meta: {
                    title: "经典算法诊断"
                },
                component: () => _import("codeAdmin/components/addAlgoFile.vue")
            },

            //经典算法预测
            {
                path: "/code/predictList",
                name: "codePredictList",
                meta: {
                    title: "经典算法预测"
                },
                component: () => _import("codePredict/index.vue")
            },

            //经典算法诊断-左列表-新增
            {
                path: "/code/addPredictDetect",
                name: "addDetect",
                meta: {
                    title: "经典算法诊断"
                },
                component: () => _import("codePredict/components/addDetect.vue")
            },

            //经典算法诊断-右列表-新增
            {
                path: "/code/addPredictAlgoFile",
                name: "addAlgoFile",
                meta: {
                    title: "经典算法诊断"
                },
                component: () =>
                    _import("codePredict/components/addAlgoFile.vue")
            },

            /**
             * 系统管理
             * */

            // 项目管理
            {
                path: "/ItemAdmin",
                name: "Item",
                meta: {
                    title: "项目管理"
                },
                component: () => _import("itemAdmin/index.vue")
            },
            {
                path: "/addItem",
                name: "AddItem",
                meta: {
                    title: "新增项目"
                },
                component: () => _import("itemAdmin/components/addItem.vue")
            },
            {
                path: "/itemDetail",
                name: "itemDetail",
                meta: {
                    title: "项目详情"
                },
                component: () => _import("itemAdmin/components/itemDetail.vue")
            },
            // 字典管理
            {
                path: "/dictAdmin",
                name: "Dict",
                meta: {
                    title: "字典管理"
                },
                component: () => _import("dictAdmin/index.vue")
            },
            {
                path: "/addDict",
                name: "AddDict",
                meta: {
                    title: "新增字典"
                },
                component: () => _import("dictAdmin/components/addDict.vue")
            },
            {
                path: "/dictDetail",
                name: "DictDetail",
                meta: {
                    title: "字典详情"
                },
                component: () => _import("dictAdmin/components/dictDetail.vue")
            },

            {
                path: "/addOption",
                name: "AddOption",
                meta: {
                    title: "新增选项"
                },
                component: () => _import("dictAdmin/components/addOption.vue")
            },
            {
                path: "/optionDetail",
                name: "optionDetail",
                meta: {
                    title: "选项详情"
                },
                component: () =>
                    _import("dictAdmin/components/optionDetail.vue")
            },
            //设备管理 （暂定删除）
            {
                path: "/equipAdmin/instance",
                name: "Instance",
                meta: {
                    title: "设备型号管理"
                },
                component: () => _import("equipAdmin/instance/index.vue")
            },
            {
                path: "/equipAdmin/addInstance",
                name: "AddInstance",
                meta: {
                    title: "新增设备型号",
                    breadcrumb: ["AddInstance"]
                },
                component: () =>
                    _import("equipAdmin/instance/components/addInstance.vue")
            },
            {
                path: "/equipAdmin/InstanceDetail",
                name: "InstanceDetail",
                meta: {
                    title: "设备型号详情",
                    breadcrumb: ["InstanceDetail"]
                },
                component: () =>
                    _import("equipAdmin/instance/components/instanceDetail.vue")
            },
            {
                path: "/equipAdmin/addParam",
                name: "AddParam",
                meta: {
                    title: "新增设备参数",
                    breadcrumb: ["addParam"]
                },
                component: () =>
                    _import("equipAdmin/instance/components/addParam.vue")
            },
            {
                path: "/equipAdmin/paramDetail",
                name: "ParamDetail",
                meta: {
                    title: "设备型号详情",
                    breadcrumb: ["paramDetail"]
                },
                component: () =>
                    _import("equipAdmin/instance/components/paramDetail.vue")
            },

            /**
             * 特征工程
             * */
            {
                path: "/featureEngineering",
                name: "FeatureEngineering",
                meta: {
                    title: "特征工程"
                },
                component: () => _import("featureEngineering/index.vue")
            },
            {
                path: "/addFeCanvas",
                name: "addFeCanvas",
                meta: {
                    title: "新建工程"
                },
                component: () =>
                    _import("featureEngineering/components/addFeCanvas.vue")
            },
            {
                path: "/feCanvasDetail",
                name: "feCanvasDetail",
                meta: {
                    title: "工程详情"
                },
                component: () =>
                    _import("featureEngineering/components/feCanvasDetail.vue")
            },
            {
                path: "/flowChart",
                name: "flowChart",
                meta: { title: "flowChart" },
                component: () => _import("flowChart/index.vue")
            },
            {
                path: "/algoFlow",
                name: "algoFlow",
                meta: {
                    title: "algoFlow"
                },
                component: () =>
                    _import("featureEngineering/algoFlow/index.vue")
            },
            /**
             * 权限管理
             * */
            {
                path: "/roleAdmin",
                name: "roleAdmin",
                meta: {
                    title: "角色管理"
                },
                component: () => _import("roleAdmin/index.vue")
            },
            {
                path: "/addRole",
                name: "addRole",
                meta: {
                    title: "新增角色"
                },
                component: () => _import("roleAdmin/components/addRole.vue")
            },
            {
                path: "/roleDetail",
                name: "roleDetail",
                meta: {
                    title: "角色详情"
                },
                component: () => _import("roleAdmin/components/roleDetail.vue")
            },
            {
                path: "/userAdmin",
                name: "userAdmin",
                meta: {
                    title: "用户管理"
                },
                component: () => _import("userAdmin/index.vue")
            },
            {
                path: "/addUser",
                name: "addUser",
                meta: {
                    title: "新增用户"
                },
                component: () => _import("userAdmin/components/addUser.vue")
            },
            {
                path: "/userDetail",
                name: "userDetail",
                meta: {
                    title: "用户详情"
                },
                component: () => _import("userAdmin/components/userDetail.vue")
            },
            // {
            //     path: "/menuAdmin",
            //     name: "menuAdmin",
            //     meta: {
            //         title: "菜单管理"
            //     },
            //     component: () => _import('featureEngineering/algoFlow/index.vue')
            // },
            //    数据管理
            {
                path: "/algoParams",
                name: "algoParams",
                meta: {
                    title: "算法参数"
                },
                component: () => _import("algoParams/index.vue")
            },
            {
                path: "/algoParamsDetail",
                name: "algoParamsDetail",
                meta: {
                    title: "算法参数详情"
                },
                component: () => _import("algoParams/components/paramsDetail.vue")
            },
            {
                path: "/helpInfo",
                name: "helpInfo",
                meta: {
                    title: "说明管理"
                },
                component: () => _import("helpInfo/index.vue")
            },
            {
                path: "/menuAdmin",
                name: "menuAdmin",
                meta: {
                    title: "菜单管理"
                },
                component: () => _import("menuAdmin/index.vue")
            }
        ]
    },
    {
        path: "/jupyter",
        name: "jupyter",
        meta: { title: "jupyter" },
        component: () => _import("jupyter.vue")
    }
];
let dinamicRoutes = [
    {
        path: "/",
        redirect: "/home"
        // redirect: "/model/list"
    }, {
        path: "/home",
        name: "Home",
        redirect: "/index",
        meta: {
            title: "首页"
        },
        component: () => import("@/modules/index/layout/index.vue"),
        children: [
            {
                path: "/index", //首页
                name: "index",
                meta: { title: "概览" },
                component: () => _import("Home.vue")
            },
        ],
    },
    {
        path: "/login",
        name: "login",
        meta: { title: "登录" },
        component: () => _import("login.vue")
    },] // 临时测试用
const router = new VueRouter({
    // dinamicRoutes, // 动态路由-权限
    routes, // 静态路由
    scrollBehavior(to, from, savedPosition) {
        // debugger;
        if (savedPosition) {
            return savedPosition;
        } else {
            return { x: 0, y: 0 };
        }
    }
});

router.beforeEach((to, from, next) => {
    store.commit("SET_BREADCRUMB", []);
    // const token = store.state.token
    // if(token || to.path === '/login'){
    next();
    // }else{
    //     next("/login") // 跳转登录页面
    // }
});
export default router;
